package com.ftg.learn.pattern.singleton;

/**
 * @author kangjx
 * @createTime 2022/8/9
 */
public class Sinleton4 {

    private Sinleton4(){
        System.out.println("111");
    }

    private static volatile Sinleton4 sinleton4;

    /**
     * DCL : double-checked locking
     * @return
     */
    public static Sinleton4 getSinleton4(){
        if(null == sinleton4){
            synchronized (Sinleton4.class){
                if(null == sinleton4){
                    sinleton4 = new Sinleton4();
                }
            }
        }
        return sinleton4;
    }


}
